package com.hjw.aop;

import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

/**
 * <p>Project:Academic - MapperAop<p>
 *
 * @author IvanWei玮 -- maste
 * @version 1.0
 * @DataTime 2025/4/12 14:20
 * @since 1.8
 */
@Slf4j
@Aspect
@Component
public class MapperAop {

    @Pointcut("execution(* com.hjw.service.impl.*.*(..))")
    public void serviceImpl() {
    }

    @Around("serviceImpl()")
    public Object around(ProceedingJoinPoint joinPoint) throws Throwable {
        long start = System.currentTimeMillis();
        Object proceed = joinPoint.proceed();
        long end = System.currentTimeMillis();
        System.out.println("耗费时间 ：" + (end - start));
        log.info( "{}方法执行了,耗费时间 ：{}ms", joinPoint.getSignature().getName(), (end - start));
        return proceed;
    }
}
